package com.team7.home.controller;

import com.team7.common.vo.CommonResult;
import com.team7.common.vo.ZoneVo;
import com.team7.home.service.ZoneService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: team7-object-master
 * @description:
 * @author: 王金涛
 * @create: 2021-10-21 10:52
 **/

@RestController
@RequestMapping("/home/zone")
public class ZoneController {

    @Autowired
    private ZoneService zoneService;

    @ApiOperation("分页查询的方法")
    @PostMapping("getAllZone/{page}/{limit}")
    public CommonResult getAllZone(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody ZoneVo ZoneVo){
        return zoneService.getAllZone(page,limit,ZoneVo);
    }

    @PostMapping("changeStatus/{id}/{isDisable}")
    public CommonResult changeStatus(@PathVariable("id") String id,@PathVariable("isDisable") Integer isDisable){
        return zoneService.changeStatus(id,isDisable);
    }

    @ApiOperation("添加")
    @PostMapping("addZone")
    public CommonResult addZone(@RequestBody ZoneVo zoneVo){
        return zoneService.addZone(zoneVo);
    }

    @PostMapping("deleteZone")
    public CommonResult deleteZone(@RequestBody ZoneVo zoneVo){
        return zoneService.deleteZone(zoneVo.getId());
    }

}
